package com.zhangsr.zus.rpc.api.protocol;

import com.zhangsr.zus.common.URL;
import com.zhangsr.zus.common.utils.ProtocolUtils;
import com.zhangsr.zus.rpc.api.Exporter;
import com.zhangsr.zus.rpc.api.Invoker;
import com.zhangsr.zus.rpc.api.RpcProtocol;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: zhangsr
 */
public abstract class AbstractProtocol implements RpcProtocol {

    protected final Map<String, Exporter<?>> exporterMap = new ConcurrentHashMap<String, Exporter<?>>();

    //todo
    protected final Set<Invoker<?>> invokers = new HashSet<Invoker<?>>();

    protected static String serviceKey(URL url) {
        return ProtocolUtils.serviceKey(url);
    }

    protected static String serviceKey(int port, String serviceVersion, String serviceGroup) {
        return ProtocolUtils.serviceKey(port, serviceVersion, serviceGroup);
    }
}
